#include "Panels.h"

#include <wx/stattext.h>
#include "data\slide_show.hpp"
#include "Communicate.h"
#include <resource_cache\resource_cache.hpp>
#include "string_conv.h"
#include "UI\interface_ids.hpp"


LeftPanel::LeftPanel(wxPanel * parent)
	: wxPanel(parent, -1, wxPoint(-1, -1), wxSize(-1, -1), wxBORDER_SUNKEN)
{
	m_parent = parent;

	m_slides_interface.assign(this);
	m_slide_data.assign(this);

	Connect(ID_TXTSLIDENAME,  wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler(LeftPanel::on_slide_rename));
	Connect(ID_LISTSLIDES, wxEVT_COMMAND_LISTBOX_SELECTED, wxCommandEventHandler(LeftPanel::on_slide_select));
	Connect(ID_BUTNEWSLIDE, wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(LeftPanel::on_new_slide) );
	Connect(ID_BUTDELETESLIDE, wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(LeftPanel::on_delete_slide) );
	Connect(ID_BUTSELECTSLIDEBG, wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(LeftPanel::on_browse_background) );
	Connect(ID_TXTSLIDEBG,  wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler(LeftPanel::on_background_rename));
	Connect(ID_TXTSLIDEGRAVX,  wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler(LeftPanel::on_gravity_x));
	Connect(ID_TXTSLIDEGRAVY,  wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler(LeftPanel::on_gravity_y));

	/// BODY CONNECTS
	Connect(ID_BUTNEWBODY, wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(LeftPanel::on_new_body) );
	Connect(ID_BUTDELETEBODY, wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(LeftPanel::on_delete_body) );
	Connect(ID_BUTSTATICBODY, wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(LeftPanel::on_switch_static) );
	Connect(ID_BUTKINEMATICBODY, wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(LeftPanel::on_switch_kinematic) );
	Connect(ID_BUTDYNAMICBODY, wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(LeftPanel::on_switch_dynamic) );
	Connect(ID_BUTBROWSEANIMATION, wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(LeftPanel::on_browse_animation) );
	Connect(ID_BUTACTIVEPOSITION, wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(LeftPanel::on_active_position) );
	Connect(ID_BUTACTIVEKINEMATIC, wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(LeftPanel::on_active_kinematic) );
	Connect(ID_BUTAPPENDKINEMATIC, wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(LeftPanel::on_append_kinematic) );
	Connect(ID_BUTDELETEKINEMATIC, wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(LeftPanel::on_delete_kinematic) );

	Connect(ID_LISTBODYS, wxEVT_COMMAND_LISTBOX_SELECTED, wxCommandEventHandler(LeftPanel::on_select_body));
	Connect(ID_LISTKINEMATICS, wxEVT_COMMAND_LISTBOX_SELECTED, wxCommandEventHandler(LeftPanel::on_select_kinematic));

	Connect(ID_TXTBODYNAME,  wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler(LeftPanel::on_change_body_name));
	Connect(ID_TXTANIMFILE,  wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler(LeftPanel::on_change_anim_file));
	Connect(ID_TXTANGLE,  wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler(LeftPanel::on_change_angle));
	Connect(ID_TXTPOSX,  wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler(LeftPanel::on_change_pos_x));
	Connect(ID_TXTPOSY,  wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler(LeftPanel::on_change_pos_y));
	Connect(ID_TXTDAMPENING,  wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler(LeftPanel::on_change_dampening));
	Connect(ID_TXTANGULARDAMP,  wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler(LeftPanel::on_change_angular_dampening));
	Connect(ID_TXTKINEX,  wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler(LeftPanel::on_change_kine_x));
	Connect(ID_TXTKINEY,  wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler(LeftPanel::on_change_kine_y));
	Connect(ID_TXTKINETIME,  wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler(LeftPanel::on_change_kine_time));
	Connect(ID_TXTKINEANGLE,  wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler(LeftPanel::on_change_kine_angle));	

	Connect(ID_CHECKFIXEDROT,  wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler(LeftPanel::on_check_fixed_rot));

	/// SHAPE CONNECTS
	Connect(ID_BUTNEWSHAPE, wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(LeftPanel::on_new_shape) );
	Connect(ID_BUTDELETESHAPE, wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(LeftPanel::on_delete_shape) );
	Connect(ID_BUTCIRCULAR, wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(LeftPanel::on_switch_circular) );
	Connect(ID_BUTPOLYGONAL, wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(LeftPanel::on_switch_polygonal) );
	Connect(ID_BUTAPPENDVERTEX, wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(LeftPanel::on_append_vertex) );
	Connect(ID_BUTDELETEVERTEX, wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(LeftPanel::on_delete_vertex) );
	Connect(ID_BUTACTIVEVERTEX, wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(LeftPanel::on_active_vertex) );
	Connect(ID_BUTACTIVECIRCLE, wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(LeftPanel::on_active_circle) );
	Connect(ID_LISTSHAPES, wxEVT_COMMAND_LISTBOX_SELECTED, wxCommandEventHandler(LeftPanel::on_switch_shape));
	Connect(ID_LISTVERTICES, wxEVT_COMMAND_LISTBOX_SELECTED, wxCommandEventHandler(LeftPanel::on_switch_vertex));
	Connect(ID_TXTDENSITY,  wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler(LeftPanel::on_change_density));
	Connect(ID_TXTRESTITUTION,  wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler(LeftPanel::on_change_restitution));
	Connect(ID_TXTFRICTION,  wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler(LeftPanel::on_change_friction));
	Connect(ID_TXTCOLLISIONMESSAGE,  wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler(LeftPanel::on_change_collision_message));
	Connect(ID_TXTVERTEXX,  wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler(LeftPanel::on_change_vertex_x));
	Connect(ID_TXTVERTEXY,  wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler(LeftPanel::on_change_vertex_y));
	Connect(ID_TXTCIRCLEOFFSETX,  wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler(LeftPanel::on_change_circle_x));
	Connect(ID_TXTCIRCLEOFFSETY,  wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler(LeftPanel::on_change_circle_y));
	Connect(ID_TXTRADIUS,  wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler(LeftPanel::on_change_radius));
	Connect(ID_CHECKSENSOR,  wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler(LeftPanel::on_check_sensor));
}

void LeftPanel::clear_ui()
{
	clear_slide_ui();
	clear_body_ui();
	clear_shape_ui();
}



///// RIGHT 

RightPanel::RightPanel(wxPanel * parent)
	: wxPanel(parent, wxID_ANY, wxDefaultPosition, 
	wxSize(850, 850), wxBORDER_SUNKEN)
{
	m_text = new wxStaticText(this, -1, wxT("0"), wxPoint(0, 0));
	m_canvas = new MyCanvas( this, wxID_ANY, wxPoint(10, 30), wxSize(805, 805));
}
